# -*- coding: utf-8 -*-

from typing import List


def l_padding(origin: str, expect_len: int, padding_char: str):
    current_len = len(origin)
    if current_len >= expect_len:
        return origin
    len_diff = expect_len - current_len
    while len_diff > 0:
        origin = padding_char + origin
        len_diff = len_diff - 1
    return origin


def r_padding(origin: str, expect_len: int, padding_char: str):
    current_len = len(origin)
    if current_len >= expect_len:
        return origin
    len_diff = expect_len - current_len
    while len_diff > 0:
        origin = origin + padding_char
        len_diff = len_diff - 1
    return origin


def upper_first(origin: str):
    if origin is None or len(origin) == 0:
        return origin
    the_upper_first = origin[:1].upper()
    return the_upper_first + origin[1:]


def lower_first(origin: str):
    if origin is None or len(origin) == 0:
        return origin
    the_lower_first = origin[:1].lower()
    return the_lower_first + origin[1:]


def is_empty_line(line: str):
    if line is None:
        return True
    line = line.replace('\n', '')
    line = line.strip()
    return line == ''


def plural(word):
    if word.endswith('y'):
        return word[:-1] + 'ies'
    elif word[-1] in 'sx' or word[-2:] in ['sh', 'ch']:
        return word + 'es'
    elif word.endswith('an'):
        return word[:-2] + 'en'
    else:
        return word + 's'


def lower_list_as_set(items: List[str]):
    lower_set = set()
    for item in items:
        lower_set.add(item.lower())
    return lower_set
